/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.feerepository.client.request;

import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestException;
import org.feerepository.client.ApplicationComponentFactory;
import org.feerepository.client.constants.AppConstants;
import org.feerepository.client.controller.AreasController;
import org.feerepository.client.controller.ServiceListMapController;

public class HttpRequestFactory
{
    
    public RequestBuilder getRequestBuilder(RequestBuilder.Method method, String url)
    {
        return new RequestBuilder(method, url);
    }

    public void sendGetAreasRequest()
    {
        RequestBuilder requestBuilder = getRequestBuilder(RequestBuilder.GET,
                                    ApplicationComponentFactory.getConstantsSet().areasURL());

        try
        {
            requestBuilder.sendRequest(null, AreasController.getInstance());
        }
        catch (RequestException ex)
        {
            //Logger.getLogger(HttpRequestFactory.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void sendGetServicesForJurisdictionRequest(int jurisdictionId)
    {
         RequestBuilder requestBuilder = getRequestBuilder(RequestBuilder.GET,
                 ApplicationComponentFactory.getConstantsSet().servicesURL()+
                 "jurisdictionId=" + jurisdictionId);

        try
        {
            requestBuilder.sendRequest(null, ServiceListMapController.getInstance());
        }
        catch (RequestException ex)
        {
            //Logger.getLogger(HttpRequestFactory.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}
